package com.shayne.view.renders;

import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import com.shayne.view.domains.ModalViewItf;
import com.shayne.view.domains.ScreenMain;

public class ScreenMainRender implements RenderViewItf, ScreenMainRenderItf {
	
	private ScreenMain screenMain;

	public ScreenMainRender() {
		initAllComponent();
	}

	public ScreenMain getScreenMain() {
		return screenMain;
	}

	public void setScreenMain(ScreenMain screenMain) {
		this.screenMain = screenMain;
	}

	@SuppressWarnings("restriction")
	@Override
	public void arrangeComponent() {
		screenMain.getVb().getChildren().addAll(screenMain.getNumberOne(),screenMain.getNumberTwo(), screenMain.getSumLbl(),screenMain.getSumBtn());
		screenMain.getVb().setPadding(new Insets(VBOX_PADDING));
		screenMain.getVb().setSpacing(VBOX_SPACING);
		screenMain.getStackPane().getChildren().add(screenMain.getVb());
		screenMain.getStage().setScene(screenMain.getScene());
//		screenMain.getStage().initStyle(StageStyle.TRA);
	}

	@SuppressWarnings("restriction")
	@Override
	public void initAllComponent() {
		screenMain = new ScreenMain();
		
		screenMain.setStage(new Stage());
		screenMain.setNumberOne(new TextField());
		screenMain.setNumberTwo(new TextField());
		screenMain.setSumBtn(new Button(BTN_SUM_TEXT));
		screenMain.setSumLbl(new Label(LBL_SUM_TEXT));
		
		screenMain.setVb(new VBox());
		screenMain.setStackPane(new StackPane());
		screenMain.setScene(new Scene(screenMain.getStackPane(), WIDTH_SCENE, HEIGHT_SCENE));
		screenMain.getScene().getStylesheets().add(getClass().getResource(FILE_GENERAL_CSS).toExternalForm());
		
		arrangeComponent();
	}

	@Override
	public void updateView(ModalViewItf screenMain) {
		
		this.screenMain =(ScreenMain) screenMain;
		arrangeComponent();
	}
	
}
